import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from '@/layouts/Provider.vue'
import naive from 'naive-ui'
import emitter from '@/utils/emitter'
import * as api from '@/services'
import * as utils from '@/utils/utils'
import config from '@/config'




import router from './router'

import 'vfonts/Inter.css'
import 'vfonts/FiraCode.css'
import '@/styles/global.less'

import './permission'

const app = createApp(App)
app.use(createPinia())
app.use(router)
app.use(naive)

import VImage from '@/common/VImage/index.vue'
app.component('VImage', VImage)

import { setupGlobDirectives } from '@/directives'
// 注册全局指令
setupGlobDirectives(app)

import dayjs from 'dayjs'
import 'dayjs/locale/zh-cn'
dayjs.locale('zh-cn')

app.provide('global', {
    $api: api.default,
    $config: config,
    $emitter: emitter,
    $utils: utils,
    $dayjs: dayjs,
})

import plugins from '@/plugins' // plugins
app.use(plugins)

//程序操作监听
app.config.errorHandler = (err) => {
    console.log('---前端程序报错---', err)
}

app.mount('#app')
